package com.ivan.toolkit.swing;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.SystemColor;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class TitledPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2545861237377973662L;
	private GradientPanel gradientPanel;
	private JLabel label;

	/**
	 * Create the panel.
	 */
	public TitledPanel() {
		setLayout(new BorderLayout(0, 0));
		
		gradientPanel = new GradientPanel();
		gradientPanel.setBackground(SystemColor.activeCaption);
		gradientPanel.setBackground2(Color.WHITE);
		gradientPanel.setPreferredSize(new Dimension(32, 32));
		add(gradientPanel, BorderLayout.NORTH);
		gradientPanel.setLayout(new BoxLayout(gradientPanel, BoxLayout.X_AXIS));
		
		Component horizontalStrut = Box.createHorizontalStrut(4);
		gradientPanel.add(horizontalStrut);
		
		label = new JLabel("New label");
		label.setForeground(Color.WHITE);
		label.setFont(new Font("微软雅黑", Font.BOLD, 14));
		label.setIcon(new ImageIcon(TitledPanel.class.getResource("/images/close.png")));
		gradientPanel.add(label);

	}
	
	public void setTitleHeight(int height) {
		gradientPanel.setPreferredSize(new Dimension(10, height));
	}

	public GradientPanel getTitlePane() {
		return gradientPanel;
	}

	public JLabel getTitleLabel() {
		return label;
	}	

}
